<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');

/**
 * Extension for: TYPOlight webCMS
 *
 * The TYPOlight webCMS is an accessible web content management system that
 * specializes in accessibility and generates W3C-compliant HTML code. It
 * provides a wide range of functionality to develop professional websites
 * including a built-in search engine, form generator, file and user manager,
 * CSS engine, multi-language support and many more. For more information and
 * additional TYPOlight applications like the TYPOlight MVC Framework please
 * visit the project website http://www.typolight.org.
 *
 * This is the data container array for table tl_boxen.
 *
 * PHP version 5
 * @copyright  Christian Wenzel/Fred Bliss 2007 / computino.de Webservice 2008
 * @author     Christian Wenzel <wenzel@saiga.de>
 * @author     Fred Bliss <fred@stevensdesign.com>
 * @author     Markus Milkereit <markus@computino.de>
 * @license    GPL
 * @filesource
 */

/**
 * Load tl_content language file
 */
$this->loadLanguageFile('tl_content');
$this->loadDataContainer('tl_content');

/**
 * Table tl_boxen
 */
$GLOBALS['TL_DCA']['tl_boxen'] = array
(
  // Config
  'config' => array
  (
    'dataContainer'               => 'Table',
    'enableVersioning'            => true
  ),

  // List
  'list' => array
  (
    'sorting' => array
    (
      'mode'                    => 1,
      'fields'                  => array('modul_id','position','title'),
      'flag'                    => 1,
      'panelLayout'             => 'search,limit,filter'
    ),
    'label' => array
    (
      'fields'                  => array('position','title','content'),
      'format'                  => '<i>[%s]</i> <b>%s</b> <br />',
      'maxCharacters'           => '350'
    ),
    'global_operations' => array
    (
      'all' => array
      (
        'label'               => &$GLOBALS['TL_LANG']['MSC']['all'],
        'href'                => 'act=select',
        'class'               => 'header_edit_all',
        'attributes'          => 'onclick="Backend.getScrollOffset();"'
      )
    ),
    'operations' => array
    (
      'edit' => array
      (
        'label'               => &$GLOBALS['TL_LANG']['tl_boxen']['edit'],
        'href'                => 'act=edit',
        'icon'                => 'edit.gif'
      ),
      'copy' => array
      (
        'label'               => &$GLOBALS['TL_LANG']['tl_boxen']['copy'],
        'href'                => 'act=copy',
        'icon'                => 'copy.gif'
      ),
      'cut' => array
      (
        'label'               => &$GLOBALS['TL_LANG']['tl_boxen']['cut'],
        'href'                => 'act=paste&amp;mode=cut',
        'icon'                => 'cut.gif'
      ),
      'delete' => array
      (
        'label'               => &$GLOBALS['TL_LANG']['tl_boxen']['delete'],
        'href'                => 'act=delete',
        'icon'                => 'delete.gif',
        'attributes'          => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"'
      ),
      'show' => array
      (
        'label'               => &$GLOBALS['TL_LANG']['tl_boxen']['show'],
        'href'                => 'act=show',
        'icon'                => 'show.gif'
      )
    )
  ),

  // Palettes
  'palettes' => array
  (
    '__selector__'                => array('addImage', 'addEnclosure'),
    'default'                     => '{title_legend},title,headline;{column_legend},position,modul_id;{text_legend},content;{image_legend},addImage;{enclosure_legend:hide},addEnclosure;{pages_legend},pages;{expert_legend:hide},space,cssID'
  ),

  // Subpalettes
  'subpalettes' => array
  (
    'addImage'                    => 'singleSRC,alt,imagemargin,size,imageUrl,caption,floating,fullsize',
    'addEnclosure'                => 'enclosure'
  ),

  // Fields
  'fields' => array
  (
    'title' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_boxen']['title'],
      'exclude'                 => true,
      'inputType'               => 'text',
      'eval'                    => array('maxlength'=>255, 'tl_class'=>'w50')
    ),
    'headline' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_boxen']['headline'],
      'exclude'                 => true,
      'search'                  => true,
      'inputType'               => 'inputUnit',
      'options'                 => array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'),
      'eval'                    => array('maxlength'=>255)
    ),
    'modul_id' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_boxen']['modul_id'],
      'exclude'                 => true,
      'inputType'               => 'select',
      'filter'                  => true,
      'options_callback'        => array('tl_boxen', 'getModuls'),
      'eval'                    => array('helpwizard'=>true),
      'explanation'             => 'modul_id'
    ),
    'content' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_boxen']['content'],
      'inputType'               => 'textarea',
      'eval'                    => array('allowHTML'=>true,'preserveTags'=>true,'rte'=>'tinyMCE')
    ),
    'addImage' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_content']['addImage'],
      'exclude'                 => true,
      'inputType'               => 'checkbox',
      'eval'                    => array('submitOnChange'=>true)
    ),
    'singleSRC' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_content']['singleSRC'],
      'exclude'                 => true,
      'inputType'               => 'fileTree',
      'eval'                    => array('fieldType'=>'radio', 'files'=>true, 'mandatory'=>true, 'tl_class'=>'clr')
    ),
    'alt' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_content']['alt'],
      'exclude'                 => true,
      'inputType'               => 'text',
      'eval'                    => array('mandatory'=>true, 'rgxp'=>'extnd', 'maxlength'=>255, 'tl_class'=>'long')
    ),
    'size' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_content']['size'],
      'exclude'                 => true,
      'inputType'               => 'text',
      'eval'                    => array('multiple'=>true, 'size'=>2, 'rgxp'=>'digit', 'nospace'=>true, 'tl_class'=>'w50'),
			'save_callback' => array
			(
				array('tl_content', 'limitImageWidth')
			)
    ),
    'caption' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_content']['caption'],
      'exclude'                 => true,
      'search'                  => true,
      'inputType'               => 'text',
      'eval'                    => array('rgxp'=>'extnd', 'maxlength'=>255, 'tl_class'=>'w50')
    ),
    'floating' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_content']['floating'],
      'exclude'                 => true,
      'inputType'               => 'radioTable',
      'options'                 => array('above', 'left', 'right', 'below'),
      'eval'                    => array('cols'=>4, 'tl_class'=>'w50'),
      'reference'               => &$GLOBALS['TL_LANG']['MSC']
    ),
    'imagemargin' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_content']['imagemargin'],
      'exclude'                 => true,
      'inputType'               => 'trbl',
      'options'                 => array('px', '%', 'em', 'pt', 'pc', 'in', 'cm', 'mm'),
      'eval'                    => array('includeBlankOption'=>true, 'tl_class'=>'w50')
    ),
    'fullsize' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_content']['fullsize'],
      'exclude'                 => true,
      'inputType'               => 'checkbox',
			'eval'                    => array('tl_class'=>'w50')
    ),
    'imageUrl' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_boxen']['imageUrl'],
      'exclude'                 => true,
      'search'                  => true,
      'inputType'               => 'text',
      'eval'                    => array('rgxp'=>'url', 'maxlength'=>255, 'tl_class'=>'w50 wizard'),
      'wizard' => array
      (
        array('tl_content', 'pagePicker')
      )
    ),
    'pages' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_boxen']['pages'],
      'inputType'               => 'pageTree',
      'eval'                    => array("multiple"=>true, 'fieldType'=>'checkbox')
      ),
    'position' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_boxen']['position'],
      'inputType'               => 'text',
      'eval'                    => array('tl_class'=>'w50')
    ),
    'space' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_boxen']['space'],
      'exclude'                 => true,
      'inputType'               => 'text',
      'eval'                    => array('multiple'=>true, 'size'=>2, 'rgxp'=>'digit', 'nospace'=>true)
    ),
    'cssID' => array
    (
      'label'                   => &$GLOBALS['TL_LANG']['tl_boxen']['cssID'],
      'exclude'                 => true,
      'search'                  => true,
      'inputType'               => 'text',
      'eval'                    => array('multiple'=>true, 'size'=>2, 'maxlength'=>240, 'tl_class'=>'w50')
    )
  )
);


/**
 * Class tl_boxen
 *
 * Provide miscellaneous methods that are used by the data configuration array.
 * 
 * @copyright  Christian Wenzel/Fred Bliss 2007 / computino.de Webservice 2008
 * @author     Christian Wenzel <wenzel@saiga.de>
 * @author     Fred Bliss <fred@stevensdesign.com>
 * @author     Markus Milkereit <markus@computino.de>
 * @package    Controller
 */
class tl_boxen extends Backend
{

  /**
   * Get Moduls with type tl_boxen
   * @param array
   * @return string
   */
  public function getModuls()
  {
    $arrModuls = array();
    $objModuls = $this->Database->prepare("SELECT * FROM tl_module WHERE type=? ORDER BY box_column")
                  ->execute("contentbox");

    while ($objModuls->next())
    {
      $arrModuls[$objModuls->id] = $objModuls->name;
    }

    return $arrModuls;
  }
}
